<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/5/27
 * Time: 13:42
 */

namespace app\common\model;


use think\Model;

class ArticleTag extends Model
{
    protected  $autoWriteTimestamp = true;
    //还需要关联一个tag表
    public function tagName()
    {
        return $this->belongsTo('tag', 'tag', 'id');
    }
    public function add($id,$data)
    {
        foreach($data as $data){
            $value[] = [
                'article' => $id,
                'tag' => $data
            ];
        }

       $resutlt =  $this -> saveAll($value);
        return $resutlt;
    }

}